#include <cctype>
#include <cstdio>
#include <cstring>

namespace utl {

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }

}  // namespace utl
using utl::read;

const int N = 1e2 + 5, T = 1e4 + 5, inf = 0x3f3f3f3f, V = 125;
int n, t, f[T + V * V], g[T + V * V], v[N], c[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P2851 [USACO06DEC]The Fewest Coins G.in", "r", stdin);
  freopen("P2851 [USACO06DEC]The Fewest Coins G.out", "w", stdout);
#endif
#endif

  read(n), read(t);
  for (int i = 1; i <= n; i++) read(v[i]);
  int sum = 0, mx = 0;
  for (int i = 1; i <= n; i++) {
    read(c[i]);
    sum += c[i] * v[i];
    mx = utl::max(mx, v[i] * v[i]);
  }
  if (sum < t) {
    printf("-1\n");
    return 0;
  }
  memset(f, inf, sizeof(f));
  memset(g, inf, sizeof(g));
  g[0] = 0, f[0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = v[i]; j <= mx; j++) g[j] = utl::min(g[j], g[j - v[i]] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c[i]; j <<= 1) {
      for (int k = t + mx; k >= j * v[i]; --k)
        f[k] = utl::min(f[k], f[k - j * v[i]] + j);
      c[i] -= j;
    }
    if (c[i])
      for (int k = t + mx; k >= c[i] * v[i]; k--)
        f[k] = utl::min(f[k], f[k - c[i] * v[i]] + c[i]);
  }
  int ans = inf;
  for (int i = t; i <= t + mx; i++) ans = utl::min(ans, f[i] + g[i - t]);
  printf("%d\n", ans == inf ? -1 : ans);
  return 0;
}